﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GenericLibrary.ExtensionMethods {

    public static class EnumerableExtension {

        public static int IndexOf<T>(this IEnumerable<T> sequence, T item) {
            int index = 0;
            foreach(T t in sequence) {
                if(t.Equals(item)) {
                    return index;
                }
                index++;
            }
            return -1;
        }

        public static void ForEach<T>(this IEnumerable<T> sequence, Func<T, int, bool> func) {
            int index = 0;
            foreach(T t in sequence) {
                if(!func(t, index)) {
                    break;
                }
                index++;
            }
        }
    }
}
